package org.chipu.jnids.sce.profile;

/** Represent the anormality between 2 {@link Stats} */
public final class Anormality {
	public final byte average;
	public final byte standardDeviation;
	public final byte skewness;
	public final byte kurtosis;

	public Anormality(float average, float standardDeviation, float skewness, float kurtosis) {
		if (average < 0 || average > 10 || standardDeviation < 0 || standardDeviation > 10 || skewness < 0 || skewness > 10
			|| kurtosis < 0 || kurtosis > 10)
			throw new IllegalArgumentException("Arguments not valid: " + average + "  " + standardDeviation + "  " + skewness
				+ "  " + kurtosis);
		this.average = (byte) Math.max(0, average);
		this.standardDeviation = (byte) Math.max(0, standardDeviation);
		this.skewness = (byte) Math.max(0, skewness);
		this.kurtosis = (byte) Math.max(0, kurtosis);
	}

	/** @returns A number [0..10], where 0 means normal. */
	public byte getValue() {
		return (byte) (average * 3 + standardDeviation * 3 + skewness * 2 + kurtosis * 2);
	}

	@Override
	public String toString() {
		return getClass().getSimpleName() + ": Avrg=" + average + "  " + standardDeviation + "  " + skewness + "  " + kurtosis;
	}

	public boolean isNormal() {
		return getValue() == 0;
	}
}